<?php
	include "common.php";	
	session_start();
	error_reporting(0);
	if($_SESSION['logInCheck']!=1){
		header('Location: index.php?loginInfo=false');
	}
	$userFname = $_SESSION['userFname'];
	$userLname = $_SESSION['userLname'];
	$userName = $_SESSION['userName'];
	$systemDate=date('d-m-y');
	
	$id = $_SESSION['id'];
	$place = $_POST['place'];
	$client = $_POST['client'];
	$reason = $_POST['reason'];
	$supervisor = $_POST['supervisor'];
	$day = $_POST['day'];
	$month = $_POST['month'];
	$year = $_POST['year'];
	$day1 = $_POST['day1'];
	$month1 = $_POST['month1'];
	$year1 = $_POST['year1'];
	
	$supervisorSql = "SELECT * FROM user WHERE e_id = '$id'";
	$supervisorSqlQuery = mysql_query($supervisorSql);
	$supervisorSqlQueryResult = mysql_fetch_assoc($supervisorSqlQuery);
	
	$supervisor = $supervisorSqlQueryResult['supervisor'];
	
	$script = $year."-".$month."-".$day;
	$scriptingTime = $year1."-".$month1."-".$day1; 
	
	$sql="INSERT INTO apply_for_work_tonight(e_id, place, client, reason,approval, supervisor,work_from,work_to, status)
	VALUES ('$id','$place','$client','$reason','2','$supervisor','$script','$scriptingTime',2)";
	mysql_query($sql);

	$resultsql = "select * from apply_for_work_tonight where e_id='$id'";
	$result = mysql_query($resultsql);
	$resultsqltable = mysql_fetch_array($result);

	$refid = $resultsqltable['id'];


	$sql="INSERT INTO notification(reference_id, e_id, supervisor, Type, Reason, Status)
	VALUES ('$refid','$id','$supervisor','apply_for_work_tonight','$reason',2)";
	mysql_query($sql);
	
	$supervisorSql = "SELECT * FROM user WHERE e_id = '$supervisor'";
	$supervisorSqlQuery = mysql_query($supervisorSql);
	$supervisorSqlResult = mysql_fetch_assoc($supervisorSqlQuery);
	
	$supervisorName = $supervisorSqlResult['f_name']." ".$supervisorSqlResult['l_name'];
	
	$notificationSelectSql = "SELECT * FROM user WHERE e_id = '$supervisor' AND notification>0s";
	$notificationSelectSqlQuery = mysql_query($notificationSelectSql);
	$notificationSelectSqlQueryResult = mysql_fetch_assoc($notificationSelectSqlQuery);
		
	$notification = $notificationSelectSqlQueryResult['notification'];
	$notification++;
		
	$updateNotificationSql = "UPDATE user SET notification = '$notification' WHERE e_id = '$supervisor'";
	$updateNotificationSqlQuery = mysql_query($updateNotificationSql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="emp_index.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="show_report.css" />
<link rel="icon" type="image/ico" href="images/favicon.ico"></link> 
<link rel="shortcut icon" href="images/favicon.ico"></link>
<script src="curvycorners.src.js" type="text/javascript"></script>
<script src="login.js" type="text/javascript"></script>
<title><?php echo "Welcome to ".$userFname." ".$userLname; ?></title>
</head>
<body>
<div class="main_div_other">
	<p><img src="images/creato_logo.jpg" /></p>
    <p id="creatobd">www.creatobd.com</p>
    <p id="date"><script>document.write(new_month+" "+new_date+", "+old_date.getFullYear()+" || "+new_day);</script></p>
    <div class="other_page_icons">
    	<ul>
        	<a href="employee.php"><li><div id="home"></div><p>home</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="work_night.php" class="active"><li><div id="employee"></div><p>Work At Night</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="emp_attendance.php"><li><div id="attendance"></div><p>attendance</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="emp_leave.php"><li><div id="leave"></div><p>leave</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="notification.php"><li><div id="notification"></div><p>notification</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="emp_black_box.php"><li><div id="blackbox"></div><p>black box</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
            <a href="index.php"><li><div id="logout"></div><p>log out</p><p class="present_class"><img src="images/arrow_up.JPG" border="none"/></p></li></a>
        </ul>
    </div><!-- end of other_page_icons-->
</div><!-- end of main_div_other-->
<div class="othrpage_1">
    <p>Apply For: <a href="work_night.php?check=1">Work At Night</a> | <a href="work_night.php?check=2">Meeting</a> | 
	<a href="work_night.php?check=3">Medical Doc</a></p>
</div><!-- end of othrpage_1-->
    <div class="page_content" style="font-family:Verdana, Geneva, Tahoma, sans-serif; margin:0px !important">
		<p style="font-size:18px; text-align:center; color:#333536;">Thank you Very Much For Sending Message</p>
		<p style="font-size:18px; text-align:center; color:#333536;">He Will Be Notified Shortly</p>
		
    </div><!-- end of page_content -->
</div><!-- end of main_div-->
<div class="human_portal">
  		<p>creato human resourse portal</p>
</div><!-- end of human_portal-->

</body>
</html>